package com.gitee.beiding.cloud.easy_call.entity;

import java.util.HashMap;
import java.util.Map;

public class TypeMapper {

    private Map<String, String> classToName = new HashMap<>();

    private Map<String, String> nameToClass = new HashMap<>();

    public TypeMapper() {
    }

    public TypeMapper(String clazz, String name) {
        mapping(clazz, name);
    }

    public TypeMapper(Class clzz, String name) {
        mapping(clzz, name);
    }

    public TypeMapper mapping(Class clzz, String name) {
        //进行类型映射
        mapping(clzz.getName(), name);
        return this;
    }

    public TypeMapper mapping(String clzz, String name) {
        classToName.put(clzz, name);
        nameToClass.put(name, clzz);
        return this;
    }

    public String getClassByName(String name) {
        return nameToClass.get(name);
    }

    public String getNameByClass(String clzz) {
        return classToName.get(clzz);
    }

}
